package com.cskaoyan.day31.work1._04_proxy._02_dynamic_proxy._01_jdk_dynamic_proxy;

import com.cskaoyan.day31.work1._04_proxy._00_bean.BuyFood;
import com.cskaoyan.day31.work1._04_proxy._00_bean.User;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class _01_JdkDynamicProxyApplication {
    public static void main(String[] args) {
        ClassLoader classLoader = _01_JdkDynamicProxyApplication.class.getClassLoader();
        Class<?>[] interfaces = User.class.getInterfaces();
        User target = new User();
        InvocationHandler invocationHandler = (InvocationHandler) new InvocationHandlerCola(target);

        BuyFood proxy = (BuyFood) Proxy.newProxyInstance(classLoader,interfaces,invocationHandler);

        proxy.buyBreakfast("热干面");
        proxy.buyLunch("猪脚饭");
        proxy.buyDinner("牛肉面");
    }
}
